<template>
  <div id="app">
    <h1>翻译大师</h1>
    <h5>简单 / 易用 / 便捷</h5>
    <tran-fromin v-on:formSubmit='translateText'></tran-fromin>
    <tran-fromout v-text="resText"></tran-fromout>
  </div>
</template>

<script>
import tranFromin from './components/tranFromin'
import tranFromout from './components/tranFromout'

export default {
  name: 'App',
  components: {
    tranFromin,
    tranFromout
  },
  data: function () {
    return {
      resText: ''
    }
  },
  methods: {
    translateText (text, language) {
      this.$http.get(`https://translate.yandex.net/api/v1.5/tr.json/translate?key=trnsl.1.1.20190320T080526Z.dae585d787db10e1.02263e5696751e34d6426cffd51d8b518e8d0e1b&lang=${language}&text=${text}`).then((Response) => {
        this.resText = Response.body.text[0]
      })
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>
